from pydantic import BaseModel, Field, validator
from typing import Optional

class EquipmentBase(BaseModel):
    equipmentName: str = Field(..., description="设备名称")
    type: Optional[str] = Field(None, description="设备类型")
    status: Optional[str] = Field("normal", description="设备状态")
    specification: Optional[str] = Field(None, description="设备规格")
    position: Optional[str] = Field(None, description="设备位置")
    images: Optional[str] = Field(None, description="设备图片")
    scaling: Optional[str] = Field(None, description="缩放比例")
    zindex: Optional[str] = Field(None, description="层级")
    visibility: Optional[str] = Field(None, description="可见性")
    
class EquipmentCreate(EquipmentBase):
    equipmentId: str = Field(..., description="设备编号")

class EquipmentUpdate(BaseModel):
    equipmentName: Optional[str] = None
    type: Optional[str] = None
    status: Optional[str] = None
    specification: Optional[str] = None
    position: Optional[str] = None
    images: Optional[str] = None
    scaling: Optional[str] = None
    zindex: Optional[str] = None
    visibility: Optional[str] = None

class EquipmentDetail(EquipmentBase):
    equipmentId: str
    createdBy: Optional[str] = Field(None, description="创建人(后端自动生成)")
    createdAt: Optional[str] = Field(None, description="创建时间(后端自动生成)")
    updatedBy: Optional[str] = Field(None, description="更新人(后端自动生成)")
    updatedAt: Optional[str] = Field(None, description="更新时间(后端自动生成)") 